package com.yunhe.mapper;

import com.yunhe.javabean.Users;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {
    //使用权限框架操作 根据账号查询信息
    @Select("select * from users where username=#{username} and status=1")
    public Users selectByUserName(String username);


    //查询所有用户信息(包含权限)
    public List<Users> selectAllUser();



    //根据id查询用户信息
    public Users selectById(int id);



    //根据id修改用户
    @Update("update users set username=#{username},password=#{password},email=#{email},phoneNum=#{phoneNum},status=#{status} where id=#{id} ")
    public int updateById(Users users);



    //修改用户角色关联表数据
    //将关联表中指定userid对应的roleid修改
    @Update("update users_role set roleId=#{rid} where userid=#{uid}")
    public int updateUserRole(@Param("uid") int uid,@Param("rid") int rid);


    //删除指定用户数据
    @Delete("delete from users where id=#{id}")
    public int deleteById(int id);



    //添加用户数据
    public int insert(Users users);


    //添加用户角色关联表数据
    //将关联表中指定userid对应的roleid添加
    @Insert("insert into users_role (userId,roleId)values(#{uid},#{rid})")
    public int InsertUserRole(@Param("uid") int uid,@Param("rid") int rid);





}
